#include <stdio.h>
#include <stdlib.h>
#define MAXNUM 30
#define Status int 
#define FALSE 0
#define TRUE 1

typedef int ElemType;

typedef struct{
    ElemType arry[MAXNUM];
    int length;
}SqList , *SeqList;



void InsertSqList (SqList *L , int x )
{

    L->arry[L->length] = x;
    L->length++;
    
} 

void merge (SqList *L , SqList *M , SqList *N)
{
    int i = 0, j = 0 , k = 0;

    while (i < L->length && j < M->length)
    {
        if(L->arry[i] <= M->arry[j])
        {
            N->arry[k] = L->arry[i];
            k++;
            i++;
        }
        else
        {
            N->arry[k] = M->arry[j];
            k++;
            j++;
        }
    }

        while (i <L->length)
        {
            N->arry[k] = L->arry[i];
            i++;
            k++;
        }
        while (j < M->length)
        {
            N->arry[k] = M->arry[j];
            j++;
            k++;
        }
    

    N->length = k;


}

void output (SqList *N)
{
    int len = N->length;
    for (int i = len - 1 ; i > 0 ; i-- )
    {
        printf ("%d " , N->arry[i]);
    }
    printf ("%d" , N->arry[0]);
}

void init (SqList *L)
{
    L->length = 0;
}

int main ()
{
    SqList first;
    SqList second;
    SqList third;


    second.length = 0;
    first.length = 0;
    third.length = 0;

    int n , m;

    scanf ("%d" , &n);
    scanf ("%d" , &m);
    int tem;
    for (int i = 0 ; i < n ; i++)
    {
        
        scanf ("%d" , &tem);
        InsertSqList (&first , tem );
    }

    

    int temp;

    for (int j = 0 ; j < m ; j++)
    {
        

        scanf ("%d" , &temp);

        InsertSqList (&second ,temp);
    }

     
    merge(&first , &second , &third);

    

    output(&third);





    return 0;
}